libobs_simple\sources\linux\sources/
v4l2_input.rs1use libobs_wrapper::{
2 data::StringEnum,
3 sources::{ObsSourceBuilder, ObsSourceRef},
4};
5use num_derive::{FromPrimitive, ToPrimitive};
6
7use crate::sources::macro_helper::define_object_manager;
8
9#[repr(i64)]
10#[derive(Clone, Copy, Debug, PartialEq, Eq, FromPrimitive, ToPrimitive)]
11pub enum ObsV4L2ColorRange {
13 Default = 0,
15 Partial = 1,
17 Full = 2,
19}
20
21impl StringEnum for ObsV4L2ColorRange {
22 fn to_str(&self) -> &str {
23 match self {
24 ObsV4L2ColorRange::Default => "Default",
25 ObsV4L2ColorRange::Partial => "Partial",
26 ObsV4L2ColorRange::Full => "Full",
27 }
28 }
29}
30
31define_object_manager!(
32 #[derive(Debug)]
33 struct V4L2InputSource("v4l2_input") for ObsSourceRef {
38 #[obs_property(type_t = "string")]
40 device_id: String,
41
42 #[obs_property(type_t = "int")]
44 input: i64,
45
46 #[obs_property(type_t = "int")]
48 pixelformat: i64,
49
50 #[obs_property(type_t = "int")]
52 standard: i64,
53
54 #[obs_property(type_t = "int")]
56 dv_timing: i64,
57
58 #[obs_property(type_t = "int")]
59 resolution: i64,
60
61 #[obs_property(type_t = "int")]
62 framerate: i64,
63
64 #[obs_property(type_t = "int")]
66 color_range: i64,
67
68 #[obs_property(type_t = "bool")]
70 auto_reset: bool,
71
72 #[obs_property(type_t = "int")]
74 timeout_frames: i64,
75 }
76);
77
78impl V4L2InputSourceBuilder {
79 pub fn set_color_range_enum(self, color_range: ObsV4L2ColorRange) -> Self {
81 use num_traits::ToPrimitive;
82 self.set_color_range(color_range.to_i64().unwrap())
83 }
84}
85
86impl ObsSourceBuilder for V4L2InputSourceBuilder {}